Structures
The following structures are available globally.
-
A type-erased
Codablevalue.The
AnyCodabletype forwards encoding and decoding responsibilities to an underlying value, hiding its specific underlying type.You can encode or decode mixed-type values in dictionaries and other collections that require
EncodableorDecodableconformance by declaring their contained type to beAnyCodable.See also
AnyEncodableSee moreSee also
AnyDecodableDeclaration
Swift
@frozen struct AnyCodableextension AnyCodable : Copyable, CustomDebugStringConvertible, CustomStringConvertible, Decodable, Encodable, Equatable, Escapable, ExpressibleByArrayLiteral, ExpressibleByBooleanLiteral, ExpressibleByDictionaryLiteral, ExpressibleByExtendedGraphemeClusterLiteral, ExpressibleByFloatLiteral, ExpressibleByIntegerLiteral, ExpressibleByNilLiteral, ExpressibleByStringInterpolation, ExpressibleByStringLiteral, ExpressibleByUnicodeScalarLiteral, Hashable, Sendable, SendableMetatype, _AnyDecodable, _AnyEncodable -
A type-erased
Decodablevalue.The
AnyDecodabletype forwards decoding responsibilities to an underlying value, hiding its specific underlying type.You can decode mixed-type values in dictionaries and other collections that require
Decodableconformance by declaring their contained type to beAnyDecodable:
See morelet json = """ { "boolean": true, "integer": 42, "double": 3.141592653589793, "string": "string", "array": [1, 2, 3], "nested": { "a": "alpha", "b": "bravo", "c": "charlie" }, "null": null } """.data(using: .utf8)! let decoder = JSONDecoder() let dictionary = try! decoder.decode([String: AnyDecodable].self, from: json)Declaration
Swift
@frozen struct AnyDecodableextension AnyDecodable : Copyable, CustomDebugStringConvertible, CustomStringConvertible, Decodable, Equatable, Escapable, Hashable, _AnyDecodable -
A type-erased
Encodablevalue.The
AnyEncodabletype forwards encoding responsibilities to an underlying value, hiding its specific underlying type.You can encode mixed-type values in dictionaries and other collections that require
Encodableconformance by declaring their contained type to beAnyEncodable:
See morelet dictionary: [String: AnyEncodable] = [ "boolean": true, "integer": 42, "double": 3.141592653589793, "string": "string", "array": [1, 2, 3], "nested": [ "a": "alpha", "b": "bravo", "c": "charlie" ], "null": nil ] let encoder = JSONEncoder() let json = try! encoder.encode(dictionary)Declaration
Swift
@frozen struct AnyEncodableextension AnyEncodable : Copyable, CustomDebugStringConvertible, CustomStringConvertible, Encodable, Equatable, Escapable, ExpressibleByArrayLiteral, ExpressibleByBooleanLiteral, ExpressibleByDictionaryLiteral, ExpressibleByExtendedGraphemeClusterLiteral, ExpressibleByFloatLiteral, ExpressibleByIntegerLiteral, ExpressibleByNilLiteral, ExpressibleByStringInterpolation, ExpressibleByStringLiteral, ExpressibleByUnicodeScalarLiteral, Hashable, _AnyEncodable -
LicenseSpring error.
See moreDeclaration
Swift
struct LSErrorextension LSError : Copyable, CustomNSError, Error, Escapable, Sendable, SendableMetatype
Structures Reference